﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using KendoMvcUI.Core;
using KendoMvcUI.Common;
using System.Web.Mvc;

namespace KendoMvcUI.UI
{
    public class PanelBar:KendoUIBase
    {
        public PanelBar(KendoUIControlSettings settings,ViewContext context,IViewDataContainer viewDataContainer)
            :base(settings,context,viewDataContainer)
        { }
    }
    public class PanelBarSettings : KendoBindingBase
    {
        public PanelBarSettings()
            : base("kendoPanelBar")
        { }
        public Action<AnimationSettings> Animation { get; set; }
        [PropertySetting(IsIngoreForJavaScript = true)]
        public List<string> ContentUrls { get; set; }
        /// <summary>
        /// Specifies how the PanelBar items are displayed when 
        /// opened and closed. The following values are available:
        /// "single","multiple"
        /// </summary>
        public string expandMode { get; set; }

        #region 事件

        public string On_Activate { get; set; }
        public string On_Collapse { get; set; }
        public string On_Error { get; set; }
        public string On_ContentLoad { get; set; }
        public string On_Expand { get; set; }
        public string On_Select { get; set; }
        #endregion

        public override string ToJsSettings()
        {
            var js = base.ToJsSettings();
            if (!js.EndsWith(",")&&!js.IsNullOrWhiteSpace())
                js += ",";
            if (Animation != null)
            {
                AnimationSettings animation = new AnimationSettings();
                Animation(animation);
                js += animation.ToString() + ",";
            }
            if(ContentUrls!=null&&ContentUrls.Count>0)
            {
                var urls = "";
                ContentUrls.ForEach(s =>
                {
                    if (s.IsNullOrWhiteSpace())
                        urls += "null,";
                    else
                        urls += "\"{0}\",".Formator(s);
                });
                js += "contentUrls:[{0}],".Formator(urls.TrimEnd(','));
            }
            return js.TrimEnd(',');
        }
    }
}
